package com.kaiwukj.android.ufamily.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.kaiwukj.android.mcas.integration.IRepositoryManager;
import com.kaiwukj.android.mcas.mvp.BaseModel;
import com.kaiwukj.android.ufamily.mvp.contract.ReportContract;
import com.kaiwukj.android.ufamily.mvp.http.api.service.CircleService;
import com.kaiwukj.android.ufamily.mvp.http.api.service.TypeService;
import com.kaiwukj.android.ufamily.mvp.http.entity.base.BaseObjResp;
import com.kaiwukj.android.ufamily.mvp.http.entity.requestbak.ReportRequest;
import com.kaiwukj.android.ufamily.mvp.http.entity.resultbak.ReportTypeResult;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @author Charles
 * @date 2019/8/14.
 * description：Kaiwu
 */
public class ReportModel extends BaseModel implements ReportContract.Model {

    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public ReportModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseObjResp<List<ReportTypeResult>>> requestReportType() {
        return mRepositoryManager.obtainRetrofitService(TypeService.class)
                .requestReportType();
    }


    @Override
    public Observable<BaseObjResp<Object>> postReport(ReportRequest reportRequest) {
        return mRepositoryManager.obtainRetrofitService(CircleService.class)
                .postReport(getRequestBody(mGson.toJson(reportRequest)));
    }

}
